<template>
  <div class="app-container">
    <el-form ref="queryForm" :model="form" :inline="true">
      <el-form-item label="币种" prop="coinName">
        <el-input placeholder="币种" v-model="form.coinName"></el-input>
      </el-form-item>

      <!-- <el-form-item label="查询时间" prop="times">
        <el-date-picker v-model="times" @change="changeTime" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
      </el-form-item> -->

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" @click="handleQuery('queryForm')">查询</el-button>
      </el-form-item>
    </el-form>
    <!-- 平台营收信息 -->
    <el-table :data="tableData" style="width: 100%" v-loading="loading">
      <el-table-column prop="coinName" label="币种"></el-table-column>
      <el-table-column prop="depositAmount" label="充值数量"></el-table-column>
      <el-table-column prop="withdrawAmount" label="提现数量"></el-table-column>
      <el-table-column prop="transFee" label="交易手续费"></el-table-column>
      <el-table-column prop="withdrawFee" label="提币手续费"></el-table-column>
      <el-table-column prop="minerFee" label="旷工费"></el-table-column>
      <el-table-column prop="returnAmount" label="邀请奖励(邀请返佣)"></el-table-column>
      <el-table-column prop="profitAmount" label="平台营收"></el-table-column>
    </el-table>
  </div>
</template>

<script>
import { platformProfit } from "@/api/home/income"
export default {
  data() {
    return {
      loading: true,
      tableData: [],
      form: {
        coinName: "",
        startTime: "",
        endTime: ""
      },
      times: ""
    };
  },
  watch: {
    times(val) {
      console.log(val, "val")
    }
  },
  created() {
    this.getList();
  },
  methods: {
    changeTime(val) {
      if (val) {
        let start = val[0], end = val[1];
        this.form.startTime = new Date(start).getTime()
        this.form.endTime = new Date(end).getTime()
      } else {
        this.form.startTime = ""
        this.form.endTime = ""
        delete this.form.startTime
        delete this.form.endTime
      }
    },
    handleQuery(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.getList()
        } else {
          return false;
        }
      });
    },
    getList() {
      this.loading = true
      platformProfit({
        ...this.form
      }).then(res => {
        this.loading = false;
        if (Array.isArray(res.result)) {
          this.tableData = res.result
        } else {
          this.tableData = [res.result]
        }
      }).catch(err => {
        this.loading = false;
      })
    }
  }
};
</script>

<style></style>
